package com.infonova.education.microservice.repository.entity;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import java.util.HashMap;

import javax.persistence.*;

@Entity
@Table
@XStreamAlias("product")
public class Product {

    private Long id;
    private String name;
    private HashMap<String,Double> prices;
    private HashMap<String,Integer>allowedAges;

    public Product() {
    }

    public Product(Long id, String name, HashMap<String, Double> prices, HashMap<String, Integer> allowedAges) {
        this.id = id;
        this.name = name;
        this.prices = prices;
        this.allowedAges = allowedAges;
    }
    
    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public double getPricePerLocale(String region)
    {
        return prices.get(region);
    }
    
    public void setPrices(HashMap<String,Double>prices)
    {
     
       if((prices==null))
       {
           System.out.println("Bei setPrices isnull ");
       }
       else
       {
        this.prices=(HashMap<String, Double>) prices.clone();     
       }
      
      
        
    }
    
    public int getAgePerLocale(String region)
    {
        return allowedAges.get(region);
    }
    
     public void setAges(HashMap<String,Integer>ages)
    {
        this.allowedAges=(HashMap<String, Integer>) ages.clone();
    }

    public HashMap<String, Double> getPrices() {
        return prices;
    }

    public HashMap<String, Integer> getAllowedAges() {
        return allowedAges;
    }
    
    public void setAllowedAges(HashMap<String, Integer> map)
    {
        this.allowedAges=map;
    }
     
     

}
